/*
 * Problem: 最小向量积（Minimum Scalar Product）
 * Author: Yuanshun L
 * Created: 5-Dec-2021
 * Topic: 排序法
 */
#include<iostream>
#include<algorithm>

using namespace std;

const int maxn = 8+1;
int x[maxn],y[maxn];
int n;

int solve(){
    int res = 0;
    sort(x,x+n);
    sort(y,y+n);
    for(int i=0;i<n;i++){
        res += x[i]*y[n-1-i];
    }
    return res;
}

int main(){
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        cin >> y[i];
    }
    cout << solve() << endl;

    return 0;
}
